package findMaxConsecutiveOnes;

public class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
        int r = 0;
        int l = 0;
        int res = 0;
        while(l<nums.length){
            if(nums[l]==0){
                l++;
            }
            r = l;
            while(r<nums.length){
                if(nums[r]==1){
                    r++;
                }else{
                    break;
                }
            }
            res = Math.max(res,r-l);
            l = r+1;
        }
        return res;
        //           r
        // 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1
        //       l
    }
}
